package cn.cjxy.javaweb.servlet.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author huangjie
 * @date 2025/9/29
 */
@WebServlet("/respDemo1")
public class ResponseDemo1 extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //往作用域中设置值
        req.setAttribute("user","zhangsan");
        //重定向到demo2
        resp.sendRedirect("/respDemo2");

    }
}
